//聊天界面
import QtQuick 2.12
import QtQuick.Controls 2.5
import QtQuick.Layouts 1.12
import QtQml 2.12
Rectangle {
    property var friendListData:[

        {id:82,userId:"12312",friendId:"23",friendName:"张飞",phone:"17760659134",remark:null,relation:1,birthdate:null,addDatetime:"2023-10-10T04:59:28",addRemark:"我",gender:0,introduce:null,headImg:"https://tse1-mm.cn.bing.net/th/id/OIP-C.ZtrvDWpDrJNiyRQj6DwPvwAAAA?rs=1&pid=ImgDetMain"},

        // { friendUserImg: "https://tse1-mm.cn.bing.net/th/id/OIP-C.ZtrvDWpDrJNiyRQj6DwPvwAAAA?rs=1&pid=ImgDetMain",friendNmae: "阿娇      ",friendMessage:"你在干嘛呢?",friendMessageTime:"21:45"},
        // { friendUserImg: "https://p.qqan.com/up/2021-4/16191446227432875.jpg",friendNmae: "小西",friendMessage:"为什么不理我?",friendMessageTime:"16:40"},
        // { friendUserImg: "https://www.telnote.cn/uploads/touxiang/80/014126751420.jpeg", friendNmae: "妍妍",friendMessage:"理我一下好不好?",friendMessageTime:"6:45"},
        // { friendUserImg: "https://p.qqan.com/up/2021-7/16254525572730039.jpg", friendNmae: "小蒙",friendMessage:"到底在干嘛?",friendMessageTime:"10:05"},
        // { friendUserImg: "https://p.qqan.com/up/2021-1/16118933074267713.jpg", friendNmae: "大吕",friendMessage:"哼?",friendMessageTime:"8:24"},
        // { friendUserImg: "https://tse3-mm.cn.bing.net/th/id/OIP-C.nnOMtJyMvYeZssL5CWwsLAAAAA?rs=1&pid=ImgDetMain", friendNmae: "胡佳",friendMessage:"生气~",friendMessageTime:"20:11"},
        // { friendUserImg: "https://p.qqan.com/up/2021-7/16264890225197706.jpg", friendNmae: "诗桥",friendMessage:"嘿?",friendMessageTime:"前天"},
        // { friendUserImg: "https://p.qqan.com/up/2019-6/2019061008021958649.jpg", friendNmae: "呱呱",friendMessage:"到底在干嘛?",friendMessageTime:"19:45"},
        // { friendUserImg: "https://p.qqan.com/up/2018-5/2018050810410773085.jpg", friendNmae: "小伦",friendMessage:"哈哈哈哈",friendMessageTime:"昨天"},
        // { friendUserImg: "https://tse1-mm.cn.bing.net/th/id/OIP-C.ZtrvDWpDrJNiyRQj6DwPvwAAAA?rs=1&pid=ImgDetMain", friendNmae: "阿娇      ",friendMessage:"你在干嘛呢?",friendMessageTime:"21:45"},
        // { friendUserImg: "https://p.qqan.com/up/2021-4/16191446227432875.jpg", friendNmae: "小西",friendMessage:"为什么不理我?",friendMessageTime:"16:40"},
        // { friendUserImg: "https://www.telnote.cn/uploads/touxiang/80/014126751420.jpeg", friendNmae: "妍妍",friendMessage:"理我一下好不好?",friendMessageTime:"6:45"},
        // { friendUserImg: "https://p.qqan.com/up/2021-7/16254525572730039.jpg",friendNmae: "小蒙",friendMessage:"到底在干嘛?",friendMessageTime:"10:05"},
        // { friendUserImg: "https://p.qqan.com/up/2021-1/16118933074267713.jpg", friendNmae: "大吕",friendMessage:"哼?",friendMessageTime:"8:24"},
        // { friendUserImg: "https://tse3-mm.cn.bing.net/th/id/OIP-C.nnOMtJyMvYeZssL5CWwsLAAAAA?rs=1&pid=ImgDetMain", friendNmae: "胡佳",friendMessage:"生气~",friendMessageTime:"20:11"},
        // { friendUserImg: "https://p.qqan.com/up/2021-7/16264890225197706.jpg", friendNmae: "诗桥",friendMessage:"嘿?",friendMessageTime:"前天"},
        // { friendUserImg: "https://p.qqan.com/up/2019-6/2019061008021958649.jpg", friendNmae: "呱呱",friendMessage:"到底在干嘛?",friendMessageTime:"19:45"},
        // { friendUserImg: "https://p.qqan.com/up/2018-5/2018050810410773085.jpg", friendNmae: "小伦",friendMessage:"哈哈哈哈",friendMessageTime:"昨天"}
    ]

    anchors.fill: parent
    color: "#ffffff"

        SerchMenuPage{
            id:serchMenuPage
            anchors.top: parent.top
            iconUrl:"qrc:/images/zengjiaIcon"
        }
        Rectangle{
            anchors.top: serchMenuPage.bottom
            width: parent.width
            height: parent.height-serchMenuPage.height
            color:"red"
            visible:!friendListViewBox.visible
        }

        Rectangle{
            id:friendListViewBox

            visible:true
            anchors.top: serchMenuPage.bottom
            width: parent.width
            height: parent.height-serchMenuPage.height
            color:"#ebe8e7"

            ListView {
                id:friendListView
                anchors.fill:parent
                enabled: true  //子项互动
                interactive: true;//元素可拖动
                clip: true //创建销毁
                focus: true

                highlight:Rectangle{
                    color:"#c9c7c6"
                }

                ScrollBar.vertical: ScrollBar {
                    id: scrollBar
                    onActiveChanged: {

//                        console.log("onActiveChanged========================")
                        active = true;
                    }
                    Component.onCompleted: {

//                        console.log("Component.onCompleted========================")
                    }
                }

                model: ListModel {
                    id: userListData
                }

                delegate: userListDatadelegate
            }

        }


    Component{
        id:userListDatadelegate
        Rectangle {
            id:userListDatadelegateItem
            height: 82
            width: parent.width
            color:"transparent"
            MouseArea{
                anchors.fill: parent;
                hoverEnabled: true;
                onEntered: {    //鼠标移入



                }
                onExited: {


                }
                onClicked:{

                    friendListView.currentIndex=index
                    var user={
                    friendName:friendName,
                    headImg:headImg
                    }
                  rightLaoder.laderGoto("RightChatPage.qml",user)
                }

            }
            Image{
                id:userImg
                source:headImg
                height: 50
                width: 50
                anchors.top: parent.top
                anchors.topMargin: (parent.height-userImg.height)/2
                anchors.left: parent.left
                anchors.leftMargin: 15

            }
            Text {
                anchors.top: parent.top
                anchors.topMargin: 20
                anchors.left: userImg.right
                anchors.leftMargin: 10
                text: friendName
                font.bold: true
                font.pixelSize: 16


            }

            // Text {
            //     anchors.bottom:  parent.bottom
            //     anchors.bottomMargin: 20
            //     anchors.left: userImg.right
            //     anchors.leftMargin: 10
            //     font.bold: true
            //     text: friendMessage
            //     color:"#999999"
            // }

            // Text {
            //     anchors.top:  parent.top
            //     anchors.topMargin: 15
            //     anchors.right: parent.right
            //     anchors.rightMargin: 20
            //     text: friendMessageTime
            //     font.pixelSize: 16

            //     font.bold: true
            //     color:"#b9b9b9"
            // }
        }
    }

    Component.onCompleted: {
        userListData.append(friendListData)}
}

